import path from 'path';
import resolve from '@rollup/plugin-node-resolve';
// import sourcemaps from 'rollup-plugin-sourcemaps';
import esbuild from 'rollup-plugin-esbuild';
// import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import jscc from 'rollup-plugin-jscc';
import repo from './package.json';
import { defineConfig } from 'rollup';
import dts from 'rollup-plugin-dts';

const bundleTarget = 'es2017';
const moduleTarget = 'es2020';

const banner = [
    `/*!`,
    ` * ${repo.name} - v${repo.version}`,
    ` * Compiled ${(new Date()).toUTCString().replace(/GMT/g, 'UTC')}`,
    ` *`,
    ` * ${repo.name} is licensed under the MIT License.`,
    ` * http://www.opensource.org/licenses/mit-license`,
    ` */`,
].join('\n');
const commonPlugins = [
    // sourcemaps(),
    resolve({
        browser: true,
        preferBuiltins: false,
    }),
    json(),
];
const plugins = [
    // dts({
    //     tsconfig: path.resolve(__dirname, "./tsconfig.type.json")
    // }),
    jscc({ values: { _VERSION: repo.version, _DEBUG: true } }),
    esbuild({ target: moduleTarget }),
];
const input = path.resolve(__dirname, "src/index.ts")
export default defineConfig([{
    input,
    output: {
        file: "dist/index.js",
        format: "umd",
        name: "engine77",
        sourcemap: false,
        exports: "auto",
        banner: banner
    },
    plugins: plugins
}
])